<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: tax_classes.php 122 2013-09-21 12:10:16Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 122 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:10:16 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

if ($_GET['action']) {
	switch ($_GET['action']) {
		case 'insert':
			$tax_class_title = $_POST['tax_class_title'];
			$tax_class_description = $_POST['tax_class_description'];
			$date_added = $_POST['date_added'];

			$db->db_query("INSERT INTO
							".TABLE_TAX_CLASS."
							(tax_class_title, tax_class_description, date_added)
						VALUES
							(".$db->db_prepare($tax_class_title).", ".$db->db_prepare($tax_class_description).", now())");
			redirect(href_link(FILENAME_TAX_CLASSES));
		break;

		case 'save':
			$tax_class_id = $_GET['tID'];
			$tax_class_title = $_POST['tax_class_title'];
			$tax_class_description = $_POST['tax_class_description'];
			$last_modified = $_POST['last_modified'];

			$db->db_query("UPDATE
								".TABLE_TAX_CLASS."
							SET
								tax_class_id = ".$db->db_prepare($tax_class_id).",
								tax_class_title = ".$db->db_prepare($tax_class_title).",
								tax_class_description = ".$db->db_prepare($tax_class_description).",
								last_modified = NOW()
							WHERE
								tax_class_id = ".$db->db_prepare($tax_class_id));
			redirect(href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tax_class_id));
		break;

		case 'deleteconfirm':
			$tax_class_id = $_GET['tID'];

			$db->db_query("DELETE FROM ".TABLE_TAX_CLASS." WHERE tax_class_id = ".$db->db_prepare($tax_class_id));
			redirect(href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page']));
		break;
	}
}
require(DIR_WS_INCLUDES.'metatag.php'); ?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellspacing="0" cellpadding="0">
	<tr>
	    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
			<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
		</td>
	    <td class="boxCenter" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="2">
				<tr>
					<td>
						<table class="table_pageHeading" width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
							</tr>
						</table>
					</td>
				</tr>
			      <tr>
			        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
			          <tr>
			            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">
			              <tr class="dataTableHeadingRow">
			                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TAX_CLASSES; ?></td>
			                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
			              </tr>
						<?php
						  $classes = $db->db_query("SELECT 
						  								tax_class_id, 
						  								tax_class_title, 
						  								tax_class_description, 
						  								last_modified, 
						  								date_added 
						  							FROM 
						  								".TABLE_TAX_CLASS." 
						  							ORDER BY 
						  								tax_class_title");
						  while(!$classes->EOF) {
						    if (((!$_GET['tID']) || (@$_GET['tID'] == $classes->fields['tax_class_id'])) && (!$tcInfo) && (substr($_GET['action'], 0, 3) != 'new')) {
						      $tcInfo = new objectInfo($classes->fields);
						    }

						    if ( (is_object($tcInfo)) && ($classes->fields['tax_class_id'] == $tcInfo->tax_class_id) ) {
						      echo '              <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\''.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id.'&action=edit').'\'">'."\n";
						    } else {
						      echo'              <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\''.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$classes->fields['tax_class_id']).'\'">'."\n";
						    }
						?>
						                <td class="dataTableContent"><?php echo $classes->fields['tax_class_title']; ?></td>
						                <td class="dataTableContent" align="right"><?php if ( (is_object($tcInfo)) && ($classes->fields['tax_class_id'] == $tcInfo->tax_class_id) ) { echo image(DIR_WS_IMAGES.'icon_arrow_right.gif', ''); } else { echo '<a href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$classes->fields['tax_class_id']).'">'.image(DIR_WS_IMAGES.'icon_info.gif', IMAGE_ICON_INFO).'</a>'; } ?>&nbsp;</td>
						<?php
						echo '</tr>';
							$classes->MoveNext();
						  }
						?>
						</table>
						<?php if (!$_GET['action']) { ?>
						<table width="100%">
							 <tr>
			                    <td colspan="2" align="right"><?php echo '<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&action=new').'">'.BUTTON_NEW_TAX_CLASS.'</a>'; ?></td>
			                  </tr>
						</table>
						<?php } ?>
						</td>
					<?php
					  $heading = array();
					  $contents = array();
					  switch ($_GET['action']) {
					    case 'new':
					      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_NEW_TAX_CLASS.'</b>');

					      $contents = array('form' => draw_form('classes', FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&action=insert'));
					      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
					      $contents[] = array('text' => '<br />'.TEXT_INFO_CLASS_TITLE.'<br />'.draw_input_field('tax_class_title'));
					      $contents[] = array('text' => '<br />'.TEXT_INFO_CLASS_DESCRIPTION.'<br />'.draw_input_field('tax_class_description'));
					      $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'.BUTTON_INSERT.'</button>&nbsp;<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page']).'">'.BUTTON_CANCEL.'</a>');
					      break;

					    case 'edit':
					      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_EDIT_TAX_CLASS.'</b>');

					      $contents = array('form' => draw_form('classes', FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id.'&action=save'));
					      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
					      $contents[] = array('text' => '<br />'.TEXT_INFO_CLASS_TITLE.'<br />'.draw_input_field('tax_class_title', $tcInfo->tax_class_title));
					      $contents[] = array('text' => '<br />'.TEXT_INFO_CLASS_DESCRIPTION.'<br />'.draw_input_field('tax_class_description', $tcInfo->tax_class_description));
					      $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'. BUTTON_UPDATE.'</button>&nbsp;<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id).'">'.BUTTON_CANCEL.'</a>');
					      break;

					    case 'delete':
					      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_DELETE_TAX_CLASS.'</b>');

					      $contents = array('form' => draw_form('classes', FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id.'&action=deleteconfirm'));
					      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
					      $contents[] = array('text' => '<br /><b>'.$tcInfo->tax_class_title.'</b>');
					      $contents[] = array('align' => 'center', 'text' => '<br /><input type="submit" class="button" onClick="this.blur();" value="'.BUTTON_DELETE.'"/>&nbsp;<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id).'">'.BUTTON_CANCEL.'</a>');
					      break;

					    default:
					      if (is_object($tcInfo)) {
					        $heading[] = array('text' => '<b>'.$tcInfo->tax_class_title.'</b>');

					        $contents[] = array('align' => 'center', 'text' => '<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id.'&action=edit').'">'.BUTTON_EDIT.'</a> <a class="button" onClick="this.blur();" href="'.href_link(FILENAME_TAX_CLASSES, 'page='.$_GET['page'].'&tID='.$tcInfo->tax_class_id.'&action=delete').'">'.BUTTON_DELETE.'</a>');
					        $contents[] = array('text' => '<br />'.TEXT_INFO_DATE_ADDED.' '.date_short($tcInfo->date_added));
					        $contents[] = array('text' => ''.TEXT_INFO_LAST_MODIFIED.' '.date_short($tcInfo->last_modified));
					        $contents[] = array('text' => '<br />'.TEXT_INFO_CLASS_DESCRIPTION.'<br />'.$tcInfo->tax_class_description);
					      }
					      break;
					  }
					  if ( (not_null($heading)) && (not_null($contents)) ) {
					    echo '<td width="25%" class="border" valign="top">'."\n";
					    $box = new box;
					    echo $box->infoBox($heading, $contents);
					    echo '</td>'."\n";
					  }
					?>
          </tr>
          </table>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>